<%@page import="org.blackjuly.sign.data.SystemDataSource"%>
<%@page import="java.sql.Connection"%>
<%@page import="org.blackjuly.sign.service.UserService"%>
<%@page import="org.blackjuly.sign.entity.User"%>
<%@page import="org.blackjuly.sign.web.RequestManager"%>
<%@page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>

<%
RequestManager rm = new RequestManager(request);
User user = rm.getModel(User.class);  // 主要用来接收传过来的参数
UserService userService = new UserService();
Connection conn = SystemDataSource.getInstance().getConnection();
userService.setConnection(conn);
String msg = "";
String url = "index.jsp";
User userSession = null;
if(userService.checkPassword(user)) {
	userSession = userService.findUserByStudent(user.getStudent());
	session.setAttribute("user", userSession);
	msg = "登录成功，三秒后自动登录";
	url = "home.jsp";
}else{
	msg = "对不起，您还没签到，或者密码错误";
}
SystemDataSource.close(conn);
out.print(msg);
response.setHeader("refresh", "3;URL=" + url);
%>